
import { WeaBrowser,WeaRadioGroup,WeaLocaleProvider} from 'ecCom';
import { DatePicker,Select} from 'antd';
const RangePicker = DatePicker.RangePicker;
import isEqual from 'lodash/isEqual';
import * as mobx from 'mobx';
import isEmpty from 'lodash/isEmpty';

const getLabel = WeaLocaleProvider.getLabel;


/**
 * 高级查询
 * props
 * advanceSearchPara ： 高级查询数据
 */
export default class Main extends React.Component{
	constructor(props) {
		super(props);
	}

	shouldComponentUpdate(nextProps) {
		const _c = !isEqual(mobx.toJS(this.props.advanceSearchData), mobx.toJS(nextProps.advanceSearchData));
        return _c || this.props.iswf !== nextProps.iswf
        		|| this.props.advanceSearchPara.wftypename !== nextProps.advanceSearchPara.wftypename;
    }

	render(){
		const config = this.getAdvanceSearchConfig();
		return (
			<div className="advance-search-container">
				{!isEmpty(config) && <WeaRadioGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaRadioGroup@eps3ew`} config={config} onChange={this.doConditonChange.bind(this)} beforeInit={this.doBeforeInit.bind(this)}/>}
			</div>
		)
	}

	getAdvanceSearchConfig(){
		const {advanceSearchData,advanceSearchPara = {},iswf = false} = this.props;
		const {wftypename = '',} = advanceSearchPara;
		const {config = []} = advanceSearchData;
		const _config  = mobx.toJS(config);
		if(iswf){
			const showinfo = <span style={{"display":'block',"lineHeight":"32px",'marginTop':'5px'}}>{wftypename}</span>;
			_config.push({label:getLabel(16579,'流程类型'),com:showinfo,labelcol:3,fieldcol:21});
		}
		return _config;
	}

	doConditonChange(data = {}){
		const {updateAdvanceSearchPara} = this.props;
		updateAdvanceSearchPara && updateAdvanceSearchPara(data);
	}

	doBeforeInit(config,lastValueMap = {},callback){
		callback(lastValueMap);
	}
}